package lib.combination;

public class CombUtilImpl implements CombUtil {
	@Override
	public Long c(int n, int k) {
		if (n < k || n <= 0)
			return 0L;

		if (k > n - k)
			return c(n, n - k);

		Long comb = 1L;
		for (int i = 1, j = n; i <= k; i++, j--) {
			comb *= j;
			comb /= i;
		}
		return comb;
	}

	@Override
	public Long c(int n, int k, Long prevComb, int prevN, int prevK) {
		return c(n, k);
	}
}
